// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   TransactionHistoryProcessor.java

package com.boci.clientapp.history.processor;

import com.boci.clientapp.history.vo.TransactionHistoryDetailVO;
import com.boci.clientapp.history.vo.TransactionHistoryVO;
import com.boci.common.processor.AbstractResponseProcessor;
import com.boci.common.vo.ResponseVO;
import java.util.ArrayList;
import org.w3c.dom.*;

public class TransactionHistoryProcessor extends AbstractResponseProcessor
{

    public TransactionHistoryProcessor(String pXML, String pReqType)
        throws Exception
    {
        super(pXML, pReqType, "HISTORY.ERROR_");
    }

    public ResponseVO processXML()
        throws Exception
    {
        TransactionHistoryVO historyVO = new TransactionHistoryVO(getReqType(), getReturnCode());
        String strPage = getNodeValue("PAGE");
        String strTotalPage = getNodeValue("TOTAL_PAGE");
        NodeList historyDetailList = resultDocument.getElementsByTagName("RECORD");
        transformVOList(historyDetailList);
        historyVO.setPage(strPage);
        historyVO.setTotalPage(strTotalPage);
        historyVO.setTransactionHistoryDetailVOList(voList);
        return historyVO;
    }

    public void transformVOList(NodeList pNodeList)
    {
        int nodeLength = pNodeList.getLength();
        voList = new ArrayList();
        for(int i = 0; i < nodeLength; i++)
        {
            TransactionHistoryDetailVO historyDetailVO = new TransactionHistoryDetailVO(getReqType(), getReturnCode());
            Element element = (Element)pNodeList.item(i);
            String strDate = getNodeValue(element, "DATE");
            String strTransaction = getNodeValue(element, "TRANSACTION");
            String strSymbol = getNodeValue(element, "SYMBOL");
            String strPrice = getNodeValue(element, "PRICE");
            String strQuantity = getNodeValue(element, "QUANTITY");
            String strAmount = getNodeValue(element, "AMOUNT");
            String strRemark = getNodeValue(element, "REMARK");
            String strRemark_chi = getNodeValue(element, "REMARK_CHI");
            String strRemark_chs = getNodeValue(element, "REMARK_CHS");
            String strName = getNodeValue(element, "NAME");
            String strName_chi = getNodeValue(element, "NAME_CHI");
            String strName_chs = getNodeValue(element, "NAME_CHS");
            String strCurrency = getNodeValue(element, "CURRENCY");
            String strDescription = getNodeValue(element, "DESCRIPTION");
            historyDetailVO.setDate(strDate);
            historyDetailVO.setSymbol(strSymbol);
            historyDetailVO.setPrice(strPrice);
            historyDetailVO.setQuantity(strQuantity);
            historyDetailVO.setAmount(strAmount);
            historyDetailVO.setRemark(strRemark);
            historyDetailVO.setRemark_chi(strRemark_chi);
            historyDetailVO.setRemark_chs(strRemark_chs);
            historyDetailVO.setName(strName);
            historyDetailVO.setName_chi(strName_chi);
            historyDetailVO.setName_chs(strName_chs);
            historyDetailVO.setCurrency(strCurrency);
            historyDetailVO.setDescription(strDescription);
            voList.add(historyDetailVO);
        }

    }

    private ArrayList voList;
}
